﻿@{
    ViewBag.Title = "fileup";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>文件上传</h2>
<form id="testForm">
    <div id="testForm">
        <table align="center" style="margin-top:100px">
            <tr>
                <td><input id="File1" type="file" name="fileUp" /></td>
                <td><input type="button" value="上传" onclick="javascript:dian();"></td>
            </tr>
        </table>
    </div>
    @*<div>
        <textarea  id="file" rows="5" cols="150"></textarea>
    </div>*@
</form>
<script language="javascript" type="text/javascript">
   // alert(document.getElementById("File1").value);
    function dian() {
        if (document.getElementById("File1").value =="")
        {
            alert("请选择文件");
        }
        else
        {
            var formData = new FormData(document.getElementById("testForm"));
            $.ajax({
                url: '/Home/upfile',
                type: 'POST',
                data: formData,
                cache: false,
                processData: false,
                contentType: false,
                success: function (returndata) {
                    //$("#file").html(returndata);
                    alert(returndata);
                },
            })
        }
       
    }
</script>


